<?php
/**
 * Created by PhpStorm.
 * User: User
 * Date: 2017/10/9
 * Time: 18:26
 */
class circle{
    private $r;
    public function getArea(){
        return 3.14*$this->r*$this->r;
    }
    public function  __set($name,$value){
        if($name=='r' && $value<0){
            $this->r=0;
        }
        else{
            $this->$name=$value;
        }
    }
    public function __get($name){
        return $this->$name;
    }
}
$c=new circle();
$c->r=3;
print $c->getArea();
print '<br/>';
$c->r=-2;
print $c->getArea();